<template>
    <div>
        <input type="text" v-model="keyWord">
        <button @click="searchUsers" >search</button>
    </div>
</template>

<script>
    export default {
        name : "Search",
        data(){
            return {
                keyWord:"",
            }
        },
        methods:{
            searchUsers(){
                //使用resource替换掉axios
                //也是promise风格，能够一直用.调用函数的
                this.$http.get("http://localhost:8080/github/search/users?q="+this.keyWord).then(
                    response => {
                        console.log("success", response.data)
                        this.$bus.$emit('getUsers',{users:response.data.items})
                    },
                    error => {
                        console.log("error", error.message)
                    }
                )
            }
        }
    }
</script>

<style scoped>

</style>